<template>
  <div>
    <h1>Add Form</h1>
    <el-form ref="formRef" :model="form" label-width="100px">
      <el-form-item label="Name">
        <el-input v-model="form.name" />
      </el-form-item>
      <el-form-item label="Amount">
        <el-input-number v-model="form.amount" />
      </el-form-item>
    </el-form>
    <el-button type="primary" @click="onSubmit">Submit</el-button>
    <el-button @click="onClose">Cancel</el-button>
  </div>
</template>
<script setup>
import { reactive, ref, inject } from "vue";
// import { request } from "ouroboros-sdk";
// import { ElNotification } from "element-plus";
const formRef = ref(null);
const form = reactive({
  name: "",
  amount: 0,
  image: "",
});
const onClose = inject("onClose");
const onConfirm = inject("onConfirm");
console.log("formloaded", onClose, onConfirm);

const onSubmit = async () => {
  onConfirm?.();
  // return;
  // const result = await request.post("/api/master-table", form);
  // if (result?.data?.code == 0) onConfirm?.();
  // else {
  //   ElNotification({
  //     title: "Error",
  //     message: result?.data?.msg || "Failed to add form",
  //     type: "error",
  //   });
  // }
};
</script>
